DIROBJ := obj/
DIREXE := exec/
DIRHEA := include/
DIRSRC := src/

CFLAGS := -I$(DIRHEA) -c -Wall
LDFLAGS := -lrt
CC := gcc

all : dirs manager productor consumidor

dirs:
	mkdir $(DIROBJ) $(DIREXE)

manager: $(DIROBJ)manager.o $(DIROBJ)semaforoI.o $(DIROBJ)memoriaI.o
	$(CC) $(LDFLAGS) -o $(DIREXE)$@ $^

productor: $(DIROBJ)productor.o $(DIROBJ)semaforoI.o $(DIROBJ)memoriaI.o
	$(CC) $(LDFLAGS) -o $(DIREXE)$@ $^

consumidor: $(DIROBJ)consumidor.o $(DIROBJ)semaforoI.o $(DIROBJ)memoriaI.o
	$(CC) $(LDFLAGS) -o $(DIREXE)$@ $^

$(DIROBJ)%.o: $(DIRSRC)%.c
	$(CC) $(CFLAGS) $^ -o $@

clean : 
	rm -rf *~ core $(DIROBJ) $(DIREXE) $(DIRHEA)*~ $(DIRSRC)*~